import Vue from 'vue'
import Vuex from 'vuex'
import { getLocalStorage, setLocalStorage } from '@/utlis/localstorage'


Vue.use(Vuex)

export default new Vuex.Store({
  // 保存数据
  state: {
    // user: JSON.parse(localStorage.getItem('token')) || ''
    user: getLocalStorage('token') || ''
  },
  getters: {
  },
  mutations: {
    SaveToken(state, data) {
      state.user = data
      // localStorage.setItem('token', JSON.stringify(data))
      setLocalStorage('token', data)
    }
  },
  actions: {
  },
  modules: {
  }
})
